<%@page import="com.sbdcpn.utils.db.BaseDAO,
				java.util.List,
				java.util.Map"
%>

<%
	BaseDAO _dao = BaseDAO.getInstance();
%>
<SCRIPT LANGUAGE="JavaScript">
<!--

function f_setGrid() {
	f_setAccountFlag();
}

function f_setAccountFlag() {
	//alert(document.all("extend_param").value);
	var yearObj = document.all("txtYear");
	var yearMonth = document.all("extend_param").value;
	var cost_unit = document.all("cost_unit");

	var curdate = new Date();
	//alert(curdate.getYear());
	yearObj.value = curdate.getYear();

	var monthObj = document.all("selMonth");
	//alert(curdate.getMonth());
	var curMonth = curdate.getMonth() + 1;
	if (curMonth.length == 1) curMonth = "0" + curMonth;
	monthObj.value = "";//curMonth;

	if (yearMonth != "") {
		yearObj.value = yearMonth.split("-")[0];
		monthObj.value = yearMonth.split("-")[1];
		cost_unit.value = yearMonth.split("-")[2];
	}

}


function f_month_where() {
	
	//alert( );
	var varCostUnit = document.all("cost_unit").value;
	if (varCostUnit==""||varCostUnit==null)  return;

	var where_sql = "finance_zg_use_mat.account_flag = ? and finance_zg_use_mat.cost_unit_id = '"+varCostUnit+"'";
	var orgwhere_sql = document.all("orgwhere_sql").value;
	var orgwhere_value = document.all("orgwhere_value").value;
	var orgwhere_type = document.all("orgwhere_type").value;


	var yearObj = document.all("txtYear");
	var monthObj = document.all("selMonth");
    if (monthObj.value==""|| monthObj.value==null) return;

	var where_value = yearObj.value + "-" + monthObj.value;
	document.all("extend_param").value = where_value+"-"+varCostUnit;
	var where_type = "string";

	if (orgwhere_sql != "") {
		where_sql = where_sql + " and (" + orgwhere_sql + ")";
		where_value += ";" + orgwhere_value;
		where_type += ";" + orgwhere_type;
	}

	if (monthObj.value == "") {
		where_sql = orgwhere_sql;
		where_value = orgwhere_value;
		where_type = orgwhere_type;
	}

	document.all("where_sql").value = where_sql;
	document.all("where_value").value = where_value;
	document.all("where_type").value = where_type;

	f_reloadPage();
}


//-->
</SCRIPT>
<table class="gridTbl">
<tr class="gridData">
	<td class="gridData" >
	<eam:message key="column.FINANCE_NOCHECK_MAT_TAB.finance_zg_use_mat.account_flag" />: 
	<input type="text" name="txtYear" id="txtYear" size="5" value=""> -
	<select name="selMonth" id="selMonth" >
	<option value=" "></option>
	<option value="01">01</option>
	<option value="02">02</option>
	<option value="03">03</option>
	<option value="04">04</option>
	<option value="05">05</option>
	<option value="06">06</option>
	<option value="07">07</option>
	<option value="08">08</option>
	<option value="09">09</option>
	<option value="10">10</option>
	<option value="11">11</option>
	<option value="12">12</option>
	</select>
	</SELECT>

	<label id="totalDate" class="gridData"><eam:message key="text.finance.cost_unit" />: </label>
	<SELECT NAME="cost_unit">
	<option value=""></option>
	<%
		String strGetCostUnit  = "select cost_unit_id ,cost_unit_name from base_cost_unit order by cost_unit_id";
		//System.out.println(strGetCostUnit);
		List listCostUnit  = _dao.query(strGetCostUnit);
		Map mapCostUnit = null;
		String strCostUnit = null;
		String strCostUnitID = null;
		for (int kk = 0 ,mm = listCostUnit.size();kk < mm;kk++){
			mapCostUnit = (Map)listCostUnit.get(kk);
			strCostUnit = (String)mapCostUnit.get("cost_unit_name");
			strCostUnitID = (String)mapCostUnit.get("cost_unit_id");
			//System.out.println(strCostUnit);
	%>
	<option value="<%=strCostUnitID%>"><%=strCostUnit%></option>
	<%}%>

	</SELECT>
	<input type="button" name="btnTotal" value="<eam:message key="btn.keyquery" />" onclick="f_month_where();">
	</td>
</tr>
</table>